//
//  SHRBCollectionViewCell.m
//  JiFengDaRen
//
//  Created by SH_iOS on 2017/8/28.
//  Copyright © 2017年 SH_iOS. All rights reserved.
//
#import "SHRBImageModel.h"
#import "SHRBCollectionViewCell.h"
@interface SHRBCollectionViewCell()
@property(nonatomic,strong)UIImageView *rbImgView;
@property(nonatomic,strong)SHLabel *rbSubTitleLabel;

@end
@implementation SHRBCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        
        [self.rbImgView mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.width.mas_equalTo(@(__I6Width(114)));
            make.height.mas_equalTo(@(__I6Height(95)));
            make.centerX.mas_equalTo(self.contentView.mas_centerX);
            make.top.mas_equalTo(self.contentView.mas_top).with.offset(0);


            
        }];
        
        [self.rbSubTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.width.mas_equalTo(@(__I6Width(114)));
            make.height.mas_equalTo(@(__I6Width(12)));
            make.centerX.mas_equalTo(self.contentView.mas_centerX);
            make.top.mas_equalTo(self.rbImgView.mas_bottom).with.offset(__I6Height(5));
            
            
            
        }];

        
    }
    
    return self;
}

- (UIImageView *)rbImgView{
    
    if (!_rbImgView) {
        
        _rbImgView = [[UIImageView alloc]init];
        _rbImgView.image = [UIImage imageNamed:@"customView_bg"];
        [self.contentView addSubview:_rbImgView];
        
    }
    
    return _rbImgView;
}

- (SHLabel *)rbSubTitleLabel{
    
    if (!_rbSubTitleLabel) {
        
        _rbSubTitleLabel = [SHLabel labelWithTextFont:13 textColor:KSHTEXTCOLOR textAlignment:NSTextAlignmentLeft];
        _rbSubTitleLabel.text = @"照片";
        [self.contentView addSubview:_rbSubTitleLabel];
    }
    
    return _rbSubTitleLabel;
}

- (void)setRbImgUrl:(NSString *)rbImgUrl{
    
    
    [self.rbImgView sd_setImageWithURL:[NSURL URLWithString:rbImgUrl] placeholderImage:[UIImage imageNamed:@"customView_bg"]];
}

- (void)setSubTitle:(NSString *)subTitle{
    
    self.rbSubTitleLabel.text = subTitle;
    
    
}

- (void)setRbImageModel:(SHRBImageModel *)rbImageModel{
    
    if ([rbImageModel.imgKey isEqualToString:@"1021"]) {
        
        SHLog(@"===%@",rbImageModel.imgUrl);
    }
    if (![rbImageModel.imgUrl isEqualToString:rbImageModel.imgKey])
    {
        
        [self.rbImgView sd_setImageWithURL:[NSURL URLWithString:rbImageModel.imgUrl] placeholderImage:[UIImage imageNamed:@"customView_bg"]];
        
    }else{
        
        self.rbImgView.image = [UIImage imageNamed:@"customView_bg"];
    }
    
    self.rbSubTitleLabel.text = rbImageModel.imgTitle;

    
}
@end
